package run.halo.app.model.dto;

import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.User;
import run.halo.app.model.enums.MFAType;
import run.halo.app.model.enums.USERFREEZESTATUS;
import run.halo.app.model.enums.UserRoleStatusEnum;

/**
 * User output dto.
 *
 * @author johnniang
 * @date 3/16/19
 */
@Data
@ToString
@EqualsAndHashCode
public class UserDTO implements OutputConverter<UserDTO, User> {

    private Integer id;

    private String username;

    private String nickname;

    private String email;

    private String avatar;

    private String description;

    private MFAType mfaType;

    private Date createTime;

    private Date updateTime;

    private USERFREEZESTATUS freezeFlag;

    private Integer userRole;

    private String userRoleStr;

    public String getUserRoleStr() {
        if(this.userRole.equals(UserRoleStatusEnum.ADMIN.getValue())){
            return "管理员";
        }
        if(this.userRole.equals(UserRoleStatusEnum.COMMON.getValue())){
            return "普通用户";
        }
        return null;
    }
}
